<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">
//오늘날짜
var nowDate = null;
//화면에 보이는 설정된 날짜
var setDate = null;

var rooms = null;

// 0,1,2,3,4,5,6 : 일,월,화,수,목,금,토
var dayOfTheWeek = "0";
//핫 튜스 롤링
var rollCnt = 1;
var rollMaxcnt=0;
function hotRolling(){
	if(rollCnt==(rollMaxcnt-1)){
		rollCnt=0;
	}
	
	$("#hotNew > div").hide();
	$("#hot"+rollCnt).slideDown();	
	rollCnt++;
}
$(document).ready(function(){
	
	setDate = new Date(${fn:substring(selDt,0,4)},${fn:substring(selDt,4,6)-1},${fn:substring(selDt,6,8)});
	nowDate  = new Date().toString("yyyyMMdd");
	
	//객실 정보 가져오기
	var option = {
			url: "./pere101Q.do",
			data : {"p_id":'${param.p_id}'},
			success : function(json){
				rooms = json;
				changeNewDate(0);
			}
	};
	$.getJson(option);
	
});


//테이블에 쓸 객실명 가져오기
var tableRooms="";
function getTableRooms(){
	if(tableRooms==""){
		return setTableList();
	}else{
		return tableRooms;
	}
}

function changeNewDateRedirect(num){
	var ddd = setDate.clone();
	ddd.addMonths(num);
	ddd.set({day:1});
	location.href="./pere800Q.do?p_id=${param.p_id}&reservation_dt="+ddd.toString("yyyyMMdd");
}


//달력에 표시할수 있도록 테이블로 만들어둠
function setTableList(){
	//아이콘 보여줄지 여부
	var p_ico_yn = rooms.list[0].p_ico_yn;
	var html="";
	if(rooms!=null){
		$.each(rooms.list, function (i) {
			if(p_ico_yn=='Y'){
				var room_type = this.room_type;
				var img_src = "res_icon_big.gif";
				if(room_type=="F"){
					img_src ="res_icon_family.gif";
				}else if(room_type=="C"){
					img_src ="res_icon_couple.gif";
				}
				
				html+="<span class='divDel'><br/> <img src='/usr/images/"+img_src+"' width='10' height='10' border=\"0\"> "+
				"<span class=\"ptrnomal\" style=\"cursor: hand\" onMouseMove=\"trackMouse2(event)\"  "+
				"onMouseOver=\"doTooltip3(event,'할로윈','비수기주중','커플룸','원룸형','80,000원')\" "+
				"onMouseOut=\"hideTip2()\"> "+
				"<A HREF=\"/reservation/pentrip_reservation02.htm?uid=caribbean&y=2012&m=02&d=19&selectRoom=209\"> "+
				this.room_nm+"</A></span></span>";
			}else{
				html+="<span class='divDel'><br/> "+
				"<span class=\"ptrnomal\" style=\"cursor: hand\" onMouseMove=\"trackMouse2(event)\"  "+
				"onMouseOver=\"doTooltip3(event,'할로윈','비수기주중','커플룸','원룸형','80,000원')\" "+
				"onMouseOut=\"hideTip2()\"> "+
				"<A HREF=\"/reservation/pentrip_reservation02.htm?uid=caribbean&y=2012&m=02&d=19&selectRoom=209\"> "+
				this.room_nm+"</A></span></span>";
			}
			
		});
	}
	
	return html;
}

//다음달 표시 옵션
var nextMonthYn=false;

//달력을 갱신한다
function changeNewDate(plusVal){
	
	//오늘 무슨요일인지 구하기
	var dt_tmp = setDate.toString("ddd");

	//1일이 수요일이면 dateAdd = 3로 시작하기 위해 처리 0부터 시작
	for(var i=0; i < Date.CultureInfo.abbreviatedDayNames.length;i++){
		if(dt_tmp == Date.CultureInfo.abbreviatedDayNames[i]){
			dayOfTheWeek=i;
			break;
		}
	}
// 	console.log(Date.CultureInfo.abbreviatedDayNames);
	
	$(".tt").remove();
	setDate.addMonths(plusVal);
	
	setYYYYMM();
	
// 	alert(nextMonth.getDaysInMonth());
	var totalDays =setDate.getDaysInMonth();
	
	var date1 = setDate.clone();
	date1.set({day:1});
		
	var dayName = date1.toString("ddd");
	var dateAdd = 0;


	//1일이 수요일이면 dateAdd = 3로 시작하기 위해 처리 0부터 시작
	for(var i=0; i < Date.CultureInfo.abbreviatedDayNames.length;i++){
		if(dayName == Date.CultureInfo.abbreviatedDayNames[i]){
			dateAdd=i;
			break;
		}
	}

	//다음달 정보
	var chkHideMonth = setDate.getDaysInMonth()+dateAdd;
	var weekCntNext = parseInt(chkHideMonth / 7);
	if((chkHideMonth % 7)>0){
		weekCntNext++;
	}
	//weekCnt1만 씀
	
	var totalDaysAdd= totalDays+dateAdd;
	var weekCnt = parseInt(totalDaysAdd / 7);
	if((totalDaysAdd % 7)>0){
		weekCnt++;
	}

	var html="";
	for(var i=0; i < weekCnt;i++){
		html+="<tr class=\"tt\" align=\"center\" height=\"33\">";
		
		for(var j=1; j<=7;j++){
			if(j==1){
				html+="<td class=\"day"+((i*7)+j)+" redb\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";
			}else if(j==7){
				html+="<td class=\"day"+((i*7)+j)+" blueb\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";
			}else{
				html+="<td class=\"day"+((i*7)+j)+"\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";	
			}
			
		}
		html+="</tr>";
	}
	$("#calTitle").after(html);
	
	
	for(var i = 1; i <= totalDays; i++ ){
		var day = date1.toString("d");
		if(i!=1 && day=="1"){
			day=date1.toString("M.d");
		}
		
		var htm_tb="<a "+
		"href=\"./pere200Q.do?p_id=${param.p_id}&reservation_dt="+date1.toString("yyyyMMdd")+"&sel_pr_no=${param.sel_pr_no}\" "+
			"class=\"\">"+day+"</a>";
		
		var calVal = "day_"+date1.toString("yyyyMMdd");
		
		$(".day"+(i+dateAdd)).html(htm_tb);
		$(".day"+(i+dateAdd)).html(htm_tb);
		if($(".day"+(i+dateAdd)).hasClass("blueb")){
			$(".day"+(i+dateAdd)).find("a").addClass("blueb");
		}else if($(".day"+(i+dateAdd)).hasClass("redb")){
			$(".day"+(i+dateAdd)).find("a").addClass("redb");
		}
		$(".day"+(i+dateAdd)).attr("id",calVal);
		date1.add(1).days();
	}
	
	var chkNowMonth = setDate.toString("yyyy")+setDate.toString("MM");
	var nowDateYYYYMM  = new Date().toString("yyyyMM");
	if(chkNowMonth==nowDateYYYYMM){
// 		오늘 이전 자료는 숨기기
		$(".tt").find("td").each(function (i){
			if($(this).attr("id")=="day_"+nowDate){
				return false;
			}
			
			$(this).find(".divDel").remove();;

		});	
	}else if(chkNowMonth>nowDateYYYYMM){//월이 오늘보다 크면 걍 두기
		
	}else{//이전이면 모두 어둡게 처리

	}
// 	alert(1);
	changeNewDate_N();
// 
// 	calTitle	타이틀
}

//다음달 표시
function changeNewDate_N(){
// 	calTitle_N
	var nextMonth = setDate.clone().addMonths(1);
	
	var totalDays =nextMonth.getDaysInMonth();

	var date1 = nextMonth.clone();
	date1.set({day:1});
		
	var dayName = date1.toString("ddd");
	var dateAdd = 0;
	

	//1일이 수요일이면 dateAdd = 3로 시작하기 위해 처리 0부터 시작
	for(var i=0; i < Date.CultureInfo.abbreviatedDayNames.length;i++){
		if(dayName == Date.CultureInfo.abbreviatedDayNames[i]){
			dateAdd=i;
			break;
		}
	}
	

	var totalDaysAdd= totalDays+dateAdd;
	var weekCnt = parseInt(totalDaysAdd / 7);
	if((totalDaysAdd % 7)>0){
		weekCnt++;
	}
	

	var html="";
	for(var i=0; i < weekCnt;i++){
		html+="<tr class=\"tt\" align=\"center\" height=\"33\">";
		
		for(var j=1; j<=7;j++){
			if(j==1){
				html+="<td class=\"dayN"+((i*7)+j)+" redb\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";
			}else if(j==7){
				html+="<td class=\"dayN"+((i*7)+j)+" blueb\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";
			}else{
				html+="<td class=\"dayN"+((i*7)+j)+"\" bgcolor=\"#FFFFFF\" >&nbsp;&nbsp;&nbsp;</td>";	
			}
			
		}
		html+="</tr>";
	}
	$("#calTitle_N").after(html);
	

	for(var i = 1; i <= totalDays; i++ ){
		var day = date1.toString("d");
		if(i!=1 && day=="1"){
			day=date1.toString("M.d");
		}
		
		var htm_tb="<a "+
			"href=\"./pere200Q.do?p_id=${param.p_id}&reservation_dt="+date1.toString("yyyyMMdd")+"&sel_pr_no=${param.sel_pr_no}\" "+
			"class=\"\">"+day+"</a>";
		
		var calVal = "day_"+date1.toString("yyyyMMdd");
		
		$(".dayN"+(i+dateAdd)).html(htm_tb);
		if($(".dayN"+(i+dateAdd)).hasClass("blueb")){
			$(".dayN"+(i+dateAdd)).find("a").addClass("blueb");
		}else if($(".dayN"+(i+dateAdd)).hasClass("redb")){
			$(".dayN"+(i+dateAdd)).find("a").addClass("redb");
		}
		
		
		$(".dayN"+(i+dateAdd)).attr("id",calVal);
		date1.add(1).days();
	}
	//예약되어있는 룸 달력에 표시
	var option__ = {
		url: "./pere200_1Q.do",
		data : {"p_id":'${param.p_id}',"reservation_dt":"${selDt}"},
		success : function(json){
			//룸 갯수
			var roomCnt = rooms.list.length;

			//달력에 색칠하기
			if(json!=null && json.list.length>0){
// 				nowDate
				
// 				Date.compare(today, future);
				var nDataChk = new Date();
				nDataChk.set({year:Number(nowDate.substr(0,4)),month:Number(nowDate.substr(4,2))-1,day:Number(nowDate.substr(6,2))});
				$.each(json.list, function (i) {
					var nDataChk1 = new Date();
					nDataChk1.set({year:Number(this.reservation_dt.substr(0,4)),month:Number(this.reservation_dt.substr(4,2))-1,day:Number(this.reservation_dt.substr(6,2))});
					
					if(nDataChk- nDataChk1<0){
						if(roomCnt==this.cnt){
							//예약 다 찬거
							$("#day_"+this.reservation_dt).attr("bgcolor","#FAFC98");
						}else{
							//예약방이 남아 있는자료
							$("#day_"+this.reservation_dt).attr("bgcolor","#FEF0FE");
						}
					}
				
				});	
			}
			//오늘 날짜 표시 
			$("#day_"+nowDate).attr("bgcolor","#e3fefe");
			//선택된 날짜표시
			var chkIcon = "<div id=\"event\" style=\"position:absolute; z-index:0 display:block;width: 45px;\">"+
				"	<img src=\"/usr/images/res_icon_today.gif\" width=\"15\" height=\"15\" border=\"0\">"+
				"</div>";
			$("#day_${selDt}").prepend(chkIcon);
		}
	};
// 	alert(2);
	$.getJson(option__);
	//빈 테이블 그레이 처리 
	$(".tt").find("td").each(function (i){
		if($(this).html()=="&nbsp;&nbsp;&nbsp;"){
			$(this).attr("bgcolor","#F8F6F7");
		}
	});	

}
//메인 날짜 변경
function setYYYYMM(){
	$("#yyyyMMdd").html(setDate.toString("yyyy")+"년 "+setDate.toString("MM")+"월 "+setDate.toString("dd")+"일");
	$("#year").html(setDate.toString("yyyy"));
	$("#month").html(setDate.toString("MM"));
	
	var nextMonth = setDate.clone().addMonths(1);
	$("#year_N").html(nextMonth.toString("yyyy"));
	$("#month_N").html(nextMonth.toString("MM"));
	
	
}


function sendSave(type,nowYn){
	$("#src_type").val(type);
	if("N"==nowYn){
		//통계내기
		if('1'==type){
			
			var month=$("#month1").val();
			if(month.length==1){
				month="0"+month;
			}
			$("#reservation_dt").val($("#year1").val()+month);
			$("#src_pr_no").val($("#pr_no1").val());
			$("#src_week").val($("#week").val());
			
		}else if('2'==type){
			var month=$("#month2").val();
			if(month.length==1){
				month="0"+month;
			}
			$("#reservation_dt").val($("#year2").val()+month);
			$("#src_pr_no").val($("#pr_no2").val());

		}else if('3'==type){
			$("#reservation_dt").val($("#year3").val());
			$("#src_pr_no").val($("#pr_no3").val());

		}
// 		alert($("#reservation_dt").val());
// 		return false;
	}else{
		//금주통계내기
		var srcYYYY = new Date().toString("yyyy");
		var srcMM = new Date().toString("MM");
		var srcDate = new Date();
// 		srcDate.set({day:6});
		
		var srcDate_tmp = srcDate.clone();
		srcDate_tmp.set({day:1});
		var dt_tmp = srcDate_tmp.toString("ddd");

		var weekDay = 0;
		
		//1일이 수요일이면 dateAdd = 3로 시작하기 위해 처리 0부터 시작 "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
		for(var i=0; i < Date.CultureInfo.abbreviatedDayNames.length;i++){
			if(dt_tmp == Date.CultureInfo.abbreviatedDayNames[i]){
				weekDay=i;
				break;
			}
		}
		var t_day = Number(srcDate.toString("dd"))+weekDay-1;
		srcDate.set({day:7});
		var srcWEEK=Math.floor(t_day/7)+1;
		
		if('1'==type){
			$("#year1").val(srcYYYY);
			$("#month1").val(srcMM);
			$("#week").val(srcWEEK);
			
			$("#reservation_dt").val(srcYYYY+srcMM);
			$("#src_pr_no").val($("#pr_no1").val());
			$("#src_week").val(srcWEEK);
			
		}else if('2'==type){
			$("#year2").val(srcYYYY);
			$("#month2").val(srcMM);
			
			$("#reservation_dt").val(srcYYYY+srcMM);
			$("#src_pr_no").val($("#pr_no2").val());

		}else if('3'==type){
			$("#year3").val(srcYYYY);
			$("#reservation_dt").val(srcYYYY);
			$("#src_pr_no").val($("#pr_no3").val());
		}
	}
// return false;
	$("#frmData").submit();
}


</script>

<form action="./pere800Q.do" id="frmData" method="post">
	<input id="p_id" name="p_id" value="${param.p_id }" type="hidden" />
	<input id="src_type" name="src_type" value="" type="hidden" />
	<input id="reservation_dt" name="reservation_dt" value="${param.reservation_dt }" type="hidden" />
	<input id="src_pr_no" name="src_pr_no" value="" type="hidden" />
	<input id="src_week" name="src_week" value="" type="hidden" />
<table width="100%" border="0" cellspacing="0" cellpadding="10">
	<tr>
		<td><table width="100%" border="0" cellspacing="0"
				cellpadding="0">
				<tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td background="/usr/images/mypage_m01bg.gif"><table
							width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="40%"><img src="/usr/images/res_m01.gif"
									width="262" height="22"></td>
								<td width="60%" align="right"><%@ include file="/WEB-INF/jsp/usr/pe/re/pere_top.jsp"%></td>
							</tr>
						</table></td>
				</tr>
				<tr>
					<td height="20" background="/usr/images/res_mbg.gif"
						bgcolor="#F4F4F4">&nbsp;</td>
				</tr>
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="50%" align="center"><table border="0"
							cellspacing="0" cellpadding="0">
							<tr>
								<td width="70" align="left"><img
									src="/usr/images/reservation_icon_home.gif" width="47"
									height="31"></td>
								<td><IMG
									SRC="${pensionInfo.p_logo }"
									BORDER="0" height="30"></td>
							</tr>
						</table></td>
					<td width="50%">&nbsp;</td>
				</tr>
				<tr>
					<td align="center" style="padding-bottom: 5px; padding-top: 10px;"><table
							width="75%" border="0" cellspacing="0" cellpadding="0">
							<tr>
				                <td width="53"><a href="#" onclick="changeNewDateRedirect(-1);"><img src="/usr/images/res_lastm.gif" width="53" height="13"></a></td>
				                <td align="center" class="ptrroom" style="padding-top: 2px;" id="yyyyMMdd"></td>
				                <td width="53" align="right"><a href="#" onclick="changeNewDateRedirect(1);"><img src="/usr/images/res_nextm.gif" width="53" height="13"></a></td>
							</tr>
						</table></td>
					<td>&nbsp;</td>
				</tr>
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="50%" align="left" valign="top"><table border="0" width="95%"
							cellspacing="0" cellpadding="3">
							<tr>
								<td align="center" bgcolor="#EBE9EA" valign="top">
									<table width="100%" border="0" cellpadding="0" cellspacing="1"
										bgcolor="#f1f1f1">
										<tr>
											<td height="30" colspan="7" align="left" bgcolor="#FEFCFD"><table
													border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td width="10">&nbsp;</td>
														<td class="month2" id="month">02</td>
														<td class="year2" id="year">2012</td>
													</tr>
												</table></td>
										</tr>
										<tr align="center" id="calTitle">
											<td width="47" height="13" bgcolor="#FD636B"><img
												src="/usr/images/realtime_sun.jpg" width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_mon.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_tue.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_wed.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_thu.jpg"
												width="45" height="13"></td>
											<td width="47" bgcolor="#85AD29"><img
												src="/usr/images/realtime_fri.jpg" width="45" height="13"></td>
											<td width="47" bgcolor="#4EA7FB"><img
												src="/usr/images/realtime_sat.jpg" width="45" height="13"></td>
										</tr>
									</table>
								</td>
							</tr>
						</table></td>
					<td width="50%" align="right" valign="top"><table border="0" width="95%"
							cellspacing="0" cellpadding="3">
							<tr>
								<td align="center" bgcolor="#EBE9EA" valign="top">
									<table width="100%" border="0" cellpadding="0" cellspacing="1"
										bgcolor="#f1f1f1">
										<tr>
											<td height="30" colspan="7" align="left" bgcolor="#FEFCFD"><table
													border="0" cellspacing="0" cellpadding="0">
													<tr>
							                            <td width="10">&nbsp;</td>
							                            <td class="month2" id="month_N">03</td>
							                            <td class="year2" id="yyyy_N">2012</td>
							                          </tr>
												</table></td>
										</tr>
										<tr align="center" id="calTitle_N">
											<td width="47" height="13" bgcolor="#FD636B"><img
												src="/usr/images/realtime_sun.jpg" width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_mon.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_tue.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_wed.jpg"
												width="45" height="13"></td>
											<td width="47"><img src="/usr/images/realtime_thu.jpg"
												width="45" height="13"></td>
											<td width="47" bgcolor="#85AD29"><img
												src="/usr/images/realtime_fri.jpg" width="45" height="13"></td>
											<td width="47" bgcolor="#4EA7FB"><img
												src="/usr/images/realtime_sat.jpg" width="45" height="13"></td>
										</tr>
									</table>

								</td>
							</tr>
						</table></td>
				</tr>
			</table> <br>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="20" valign="top"><table width="5" border="0"
							cellspacing="0" cellpadding="0">
							<tr>
								<td bgcolor="#FF0000" height="10"></td>
							</tr>
						</table></td>
					<td valign="bottom" class="padl5"><strong>통계관리</strong></td>
				</tr>
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="1">
				<tr>
					<td height="42" align="center" bgcolor="#fafc98">매출통계는 <strong>진행상태:숙박완료</strong>
						된 데이터를 대상으로한 최종 매출 결과입니다.<br> 예약건당 1번만 계산됩니다. (2박이상은 숙박첫날에
						계산합니다.)
					</td>
				</tr>
				<tr>
<c:set var="now" value="<%=new java.util.Date()%>"/>
<fmt:formatDate value="${now}" pattern="yyyy" var="nowyyyy"/>
					<td bgcolor="#e2dede"><table width="100%" border="0"
							cellspacing="1" cellpadding="0">
							<tr>
								<td width="74" height="40" align="center" bgcolor="#f4f3f3">주간통계</td>
								<td bgcolor="#FFFFFF" class="padl5"><select name="year1" id="year1">
<c:forEach var="i" begin="${startYYYY }" end="${endYYYY }">
	<option value='${i }' <c:if test="${(empty param.year1 && nowyyyy==i) || param.year1==i }">selected="selected"</c:if>>${i }</option>
 </c:forEach>
								</select> 년 <select name="month1" id="month1">
<c:forEach var="i" begin="1" end="12">
	<c:if test="${i>9 }">
	<option value='${i }' <c:if test="${fn:substring(selDt,4,6)==i }">selected="selected"</c:if>>${i }</option>
	</c:if>
	<c:if test="${i<=9 }">
		<c:set var="aaa" value="0${i }"/>
	<option value='${aaa }' <c:if test="${fn:substring(selDt,4,6)==aaa }">selected="selected"</c:if>>${i }</option>
	</c:if>
 </c:forEach>
								</select> 월 <select name="week" id="week">
<c:forEach var="i" begin="1" end="5">
	<option value='${i }' <c:if test="${param.week==i }">selected="selected"</c:if>>${i }주</option>
 </c:forEach>
								</select> <select name="pr_no1" id="pr_no1">
										<option value="">전체</option>
	<c:if test="${rooms !=null && fn:length(rooms)>0 }">
		<c:forEach var="map1" items="${rooms}" varStatus="status">
			<option value='${map1.pr_no }' <c:if test="${param.pr_no1==map1.pr_no }">selected="selected"</c:if>>${map1.room_nm }</option>
		</c:forEach>
	</c:if>
								</select> <input type="button" onClick="sendSave('1','N')" value="통계내기">
									<input type="button" onClick="sendSave('1','Y')" value="금주통계"></td>
							</tr>
							<tr>
								<td height="40" align="center" bgcolor="#f4f3f3">월간통계</td>
								<td bgcolor="#FFFFFF" class="padl5"><select name="year2"
									id="year2">
<c:forEach var="i" begin="${startYYYY }" end="${endYYYY }">
	<option value='${i }' <c:if test="${(empty param.year1 && nowyyyy==i) || param.year2==i }">selected="selected"</c:if>>${i }</option>
 </c:forEach>
								</select> 년 <select name="month2" id="month2">
<c:forEach var="i" begin="1" end="12">
	<c:if test="${i>9 }">
	<option value='${i }' <c:if test="${fn:substring(selDt,4,6)==i }">selected="selected"</c:if>>${i }</option>
	</c:if>
	<c:if test="${i<=9 }">
		<c:set var="aaa" value="0${i }"/>
	<option value='${aaa }' <c:if test="${fn:substring(selDt,4,6)==aaa }">selected="selected"</c:if>>${i }</option>
	</c:if>
 </c:forEach>
								</select> 월 <select name="pr_no2" id="pr_no2">
											<option value="">전체</option>
	<c:if test="${rooms !=null && fn:length(rooms)>0 }">
		<c:forEach var="map1" items="${rooms}" varStatus="status">
			<option value='${map1.pr_no }' <c:if test="${param.pr_no2==map1.pr_no }">selected="selected"</c:if>>${map1.room_nm }</option>
		</c:forEach>
	</c:if>
								</select> <input type="button" onClick="sendSave('2','N')" value="통계내기">
									<input type="button" onClick="sendSave('2','Y')" value="금월통계"></td>

							</tr>
							<tr>
								<td height="40" align="center" bgcolor="#f4f3f3">년간통계</td>
								<td bgcolor="#FFFFFF" class="padl5"><select name="year3"
									id="year3">
<c:forEach var="i" begin="${startYYYY }" end="${endYYYY }">
	<option value='${i }' <c:if test="${(empty param.year1 && nowyyyy==i) || param.year3==i }">selected="selected"</c:if>>${i }</option>
 </c:forEach>
								</select> 년 <select name="pr_no3" id="pr_no3">
										<option value="">전체</option>
	<c:if test="${rooms !=null && fn:length(rooms)>0 }">
		<c:forEach var="map1" items="${rooms}" varStatus="status">
			<option value='${map1.pr_no }' <c:if test="${param.pr_no3==map1.pr_no }">selected="selected"</c:if>>${map1.room_nm }</option>
		</c:forEach>
	</c:if>
								</select> <input type="button" onClick="sendSave('3','N')" value="통계내기">
									<input type="button" onClick="sendSave('3','Y')" value="금년통계"></td>
							</tr>
						</table></td>
				</tr>
			</table>

			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td align="center">
<c:if test="${'1'==param.src_type }">
	<c:if test="${list !=null && fn:length(list)>0 }">
			<table width="100%" border="0" cellspacing="0" cellpadding="1">
				<tr>
					<td height="42" align="left" bgcolor="#fafc98"><b>${title }</b></td>
				</tr>
				<tr>
					<td height="42" align=left>
			<c:if test="${param.src_pr_no=='' }">
			객실 전체 통계
			</c:if>
			<c:if test="${param.src_pr_no!='' }">
			객실 ${list[0].room_nm } 통계
			</c:if>
						
					</td>
				</tr>
			
			</table>
			<table width="100%" border="1" cellpadding="0" cellspacing="0"
				bordercolor="#edecec" style="border-collapse: collapse;"
				bgcolor="#FEFEF6">
				<tr height=25 align="center" class="greenb2">
					<td>객실명</td>
					<td>이용인원</td>
					<td>숙박건수</td>
					<td>숙박금액</td>
					<td>수수료</td>
				</tr>
		<c:set var="man_cnt" value="0"/>
		<c:set var="sook" value="0"/>
		<c:set var="total_pay" value="0"/>
		<c:set var="ssr_total_pay" value="0"/>
		<c:forEach var="map1" items="${list}" varStatus="status">
			<c:set var="man_cnt" value="${man_cnt+map1.man_cnt }"/>
			<c:set var="sook" value="${sook+map1.sook }"/>
			<c:set var="total_pay" value="${total_pay+map1.total_pay }"/>
			<c:set var="ssr_total_pay" value="${ssr_total_pay+map1.save_pay }"/>
				<tr height="25" align="center">
					<td>${map1.room_nm }</td>
					<td>${map1.man_cnt }명</td>
					<td>${map1.sook }건</td>
					<td><fmt:formatNumber value="${map1.total_pay }" pattern="#,###"/>원</td>
					<td><fmt:formatNumber value="${map1.save_pay }" pattern="#,###"/>원</td>
				</tr>
		</c:forEach>
		<c:if test="${param.src_pr_no=='' }">
				<tr height="25" align="center">
					<td>===합계===</td>
					<td>${man_cnt }명</td>
					<td>${sook }건</td>
					<td><fmt:formatNumber value="${total_pay }" pattern="#,###"/>원</td>
					<td><fmt:formatNumber value="${ssr_total_pay }" pattern="#,###"/>원</td>
				</tr>
		</c:if>

			</table>
	</c:if>
</c:if>
<c:if test="${'2'==param.src_type }">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
	<tr>
		<td height="42" align="left" bgcolor="#fafc98"><b>${title }
			<c:if test="${param.src_pr_no=='' }">
			전체
			</c:if>
			<c:if test="${param.src_pr_no!='' }">
			${map.room_nm }
			</c:if></b>

		</td>
	</tr>
	<tr>
		<td height="42" align=left>객실별 통계</td>
	</tr>
</table>

	<c:if test="${map !=null  }">
<table width="100%" border="1" cellpadding="0" cellspacing="0"
	bordercolor="#edecec" style="border-collapse: collapse;"
	bgcolor="#FEFEF6" align="center">
	<tr height=25 align="center" class="greenb2">
		<td>기간</td>
		<td>객실</td>
		<td>이용인원</td>
		<td>숙박건수</td>
		<td>숙박금액</td>
		<td>수수료</td>
	</tr>
	<tr height="40" align="center">
		<td><b>${param.year2 }년 ${param.month2 }월</b></td>
		<td><b>
			<c:if test="${param.src_pr_no=='' }">
			전체
			</c:if>
			<c:if test="${param.src_pr_no!='' }">
			${map.room_nm }
			</c:if>
		</b></td>
		<td>${map.man_cnt }</td>
		<td>${map.sook }</td>
		<td><fmt:formatNumber value="${map.total_pay }" pattern="#,###"/></td>
		<td><fmt:formatNumber value="${map.save_pay }" pattern="#,###"/></td>
	</tr>
</table>
	</c:if>
	<c:if test="${list !=null && fn:length(list)>0 }">
<table width="100%" border="1" cellpadding="0" cellspacing="0"
	bordercolor="#edecec" style="border-collapse: collapse;"
	bgcolor="#FEFEF6">
	<tr>
		<td width="50%">
			<table width="100%" border="1" cellpadding="0" cellspacing="0"
				bordercolor="#edecec" style="border-collapse: collapse;"
				bgcolor="#FEFEF6">
				<tr height=25 align="center" class="greenb2">
					<td width="80">일자별</td>
					<td width="60">이용인원</td>
					<td width="60">숙박건수</td>
					<td width="80">숙박금액</td>
					<td>수수료</td>
				</tr>
			</table>
		</td>
		<td width="50%">
			<table width="100%" border="1" cellpadding="0" cellspacing="0"
				bordercolor="#edecec" style="border-collapse: collapse;"
				bgcolor="#FEFEF6">
				<tr height=25 align="center" class="greenb2">
					<td width="80">일자별</td>
					<td width="60">이용인원</td>
					<td width="60">숙박건수</td>
					<td width="80">숙박금액</td>
					<td>수수료</td>
				</tr>
			</table>
		</td>
	</tr>
		<c:forEach var="map1" items="${list}" varStatus="status">
<c:if test="${status.index mod 2==0 }">
	<tr>
</c:if>
		<td width="50%">
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				bordercolor="#edecec">
				<tr height=25 align="center">
					<td width="80">${fn:substring(map1.reservation_dt,2,4) }-${fn:substring(map1.reservation_dt,4,6) }-${fn:substring(map1.reservation_dt,6,8)}</td>
					<td width="60">${map1.man_cnt }</td>
					<td width="60">${map1.sook }</td>
					<td width="80"><fmt:formatNumber value="${map1.total_pay }" pattern="#,###"/></td>
					<td><fmt:formatNumber value="${map1.save_pay }" pattern="#,###"/>&nbsp;</td>
				</tr>
			</table>
		</td>
<c:if test="${status.index mod 2==1 }">
	</tr>
</c:if>
		</c:forEach>
		<c:if test="${fn:length(list) mod 2 ==1 }">
		<td width="50%">
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				bordercolor="#edecec">
				<tr height=25 align="center">
					<td width="80"> </td>
					<td width="60"></td>
					<td width="60"></td>
					<td width="80"> </td>
					<td> </td>
				</tr>
			</table>
		</td>
	</tr>
		</c:if>
</table>
	</c:if>
</c:if>
<c:if test="${'3'==param.src_type }">
<table width="100%" border="0" cellspacing="0" cellpadding="10">
	<tr>
		<td bgcolor="#fafc98" class="year">${param.year3 }년 전체</td>
	</tr>
	<tr>
		<td><table width="100%" border="0" cellspacing="0"
				cellpadding="0">
				<tr>
					<td width="50%">전체통계</td>
					<td width="50%">&nbsp;</td>
				</tr>
			</table></td>
	</tr>
</table>
	<c:if test="${list1 !=null && fn:length(list1)>0 }">
			<table width="100%" border="1" cellspacing="0" cellpadding="0"
				bordercolor="#cccccc" style="border-collapse: collapse;">
				<tr align="center" bgcolor="#f1f1f0">
					<td width="20%" height="30">객실별</td>
					<td width="10%">이용인원</td>
					<td width="10%">숙박건수</td>
					<td width="16%">숙박금액</td>
					<td width="16%">수수료</td>
				</tr>
		<c:forEach var="map1" items="${list1}" varStatus="status">
				<tr align="center">
					<td height="30">${map1.room_nm }</td>
					<td>${map1.man_cnt }명</td>
					<td>${map1.sook }건</td>
					<td><fmt:formatNumber value="${map1.total_pay }" pattern="#,###"/>원</td>
					<td><fmt:formatNumber value="${map1.save_pay }" pattern="#,###"/>원</td>
				</tr>
		</c:forEach>

			</table>
			<br/>
	</c:if>
	<c:if test="${list2 !=null && fn:length(list2)>0 }">
			<table width="100%" border="1" cellspacing="0" cellpadding="0"
				bordercolor="#cccccc" style="border-collapse: collapse;">
				<tr align="center" bgcolor="#f1f1f0">
					<td width="20%" height="30" bgcolor="#f1f1f0">월별</td>
					<td width="10%">이용인원</td>
					<td width="10%">숙박건수</td>
					<td width="16%">숙박금액</td>
					<td width="16%">수수료</td>
				</tr>
		<c:forEach var="map1" items="${list2}" varStatus="status">
				<tr align="center">
					<td height="30">${fn:substring(map1.reservation_dt,4,6)+0 }월</td>
					<td>${map1.man_cnt }명</td>
					<td>${map1.sook }건</td>
					<td><fmt:formatNumber value="${map1.total_pay }" pattern="#,###"/>원</td>
					<td><fmt:formatNumber value="${map1.save_pay }" pattern="#,###"/>원</td>
				</tr>		
		</c:forEach>
			</table>
	</c:if>
</c:if>
					</td>
				</tr>
				<tr>
					<td align="center">&nbsp;</td>
				</tr>
				<tr>
					<td height="3" bgcolor="#86ad29"></td>
				</tr>
				<tr>
					<td style="padding-top: 2px;"><%@ include file="/WEB-INF/jsp/usr/pe/re/footer.jsp"%></td>
				</tr>
			</table></td>
	</tr>
</table>
</form>